package com.hjm.project.transferGear.transferGear.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.transferGear.transferGear.domain.TransferGear;
import com.hjm.project.transferGear.transferGear.service.ITransferGearService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 划拨指标记录Controller
 * 
 * @author maker-platform
 * @date 2021-01-26
 */
@Controller
@RequestMapping("/transferGear/transferGear")
public class TransferGearController extends BaseController
{
    private String prefix = "transferGear/transferGear";

    @Autowired
    private ITransferGearService transferGearService;

    @RequiresPermissions("transferGear:transferGear:view")
    @GetMapping()
    public String transferGear()
    {
        return prefix + "/transferGear";
    }

    /**
     * 查询划拨指标记录列表
     */
    @RequiresPermissions("transferGear:transferGear:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TransferGear transferGear)
    {
        startPage();
        List<TransferGear> list = transferGearService.selectTransferGearList(transferGear);
        return getDataTable(list);
    }

    /**
     * 导出划拨指标记录列表
     */
    @RequiresPermissions("transferGear:transferGear:export")
    @Log(title = "划拨指标记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TransferGear transferGear)
    {
        List<TransferGear> list = transferGearService.selectTransferGearList(transferGear);
        ExcelUtil<TransferGear> util = new ExcelUtil<TransferGear>(TransferGear.class);
        return util.exportExcel(list, "transferGear");
    }

    /**
     * 新增划拨指标记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存划拨指标记录
     */
    @RequiresPermissions("transferGear:transferGear:add")
    @Log(title = "划拨指标记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TransferGear transferGear)
    {
        return toAjax(transferGearService.insertTransferGear(transferGear));
    }

    /**
     * 修改划拨指标记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TransferGear transferGear = transferGearService.selectTransferGearById(id);
        mmap.put("transferGear", transferGear);
        return prefix + "/edit";
    }

    /**
     * 修改保存划拨指标记录
     */
    @RequiresPermissions("transferGear:transferGear:edit")
    @Log(title = "划拨指标记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TransferGear transferGear)
    {
        return toAjax(transferGearService.updateTransferGear(transferGear));
    }

    /**
     * 删除划拨指标记录
     */
    @RequiresPermissions("transferGear:transferGear:remove")
    @Log(title = "划拨指标记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(transferGearService.deleteTransferGearByIds(ids));
    }
}
